using FluentValidation;
using Jupiter.Infrastructure.Domain;
using MediatR;

namespace Wips.AppService.Authorities.Roles.Requests
{
    /// <summary>
    /// 给角色分配职位请求类
    /// </summary>
    public class AssignPositionsForRoleRequest : IRequest<bool>,ITxRequest
    {
        /// <summary>
        /// 角色Id
        /// </summary>
        public string RoleId { get; set; }

        /// <summary>
        /// 职位Id列表
        /// </summary>
        public IList<string> PositionIds { get; set; }
    }

    /// <summary>
    /// 
    /// </summary>
    public class AssignPositionsForRoleValidator : AbstractValidator<AssignPositionsForRoleRequest>
    {
        /// <summary>
        /// 
        /// </summary>
        public AssignPositionsForRoleValidator()
        {
            RuleFor(p => p.PositionIds)
                .Must(list => list.Count > 0)
                .WithMessage("未选择职位");

            RuleFor(p => p.RoleId)
                .Must(id => !string.IsNullOrEmpty(id))
                .WithMessage("角色不能为空");
        }
    }
}